#include <iostream>
#include <string>

using namespace std;

string MealyMachine(const string &str, bool trace);

enum States { NOTSLASH, SLASH };

int main()
{
	string str = "this is /*this should not be included*/a test!";
	cout << "\nThe origional string is: " << str;
	cout << "\nThe final string is: " << MealyMachine(str, true);
	cin.get();
	return 0;
}

string MealyMachine(const string &str, bool trace)
{
	States state = NOTSLASH;
	char *keep = new char[str.length()];
	int count = 0;
	for (int i = 0; i < str.length(); i ++)
	{
		if ((state == NOTSLASH) && ((str[i] != '/') && (str[i+1] != '*')))
		{
			keep[count] = str[i];
			count ++;
		}
		else if (state == SLASH)
		{
			if ((str[i] == '/')&&(str[i-1] == '*'))
			{
				if (trace)
					cout << "\nfound a */ changing state to ~/";
				state = NOTSLASH;
			}
		}
		else
		{
			if (trace)
				cout << "\nfound a /* changing state to slash(?)";
			state = SLASH;
		}
	}
	keep[count] = 0;
	return string(keep);
}